package com.cjk.foundation.dao.file;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.cjk.foundation.entity.file.FileModuleEntity;
import com.cjk.foundation.enums.IsStatus;

@Repository
public interface FileModuleDao {

	public void insert(FileModuleEntity fileModuleEntity);
	
	@Delete("delete from file_module where group_id = #{groupId}")
	public void deleteByGroupId(@Param("groupId") Integer groupId);
	
	@ResultMap("resultMap")
	@Select("select * from file_module where group_id = #{groupId}")
	public List<FileModuleEntity> selectListByGroupId(@Param("groupId") Integer groupId);
	
	@Update("update file_module set file_name = #{fileName} where module = #{module} and group_id = #{groupId}")
	public void updateFile(@Param("module") String module, @Param("groupId") Integer groupId, @Param("fileName") String fileName);
	
	@Update("update file_module set need_update = #{needUpdate} where group_id = #{groupId}")
	public void updateStateByGroupId(@Param("groupId") Integer groupId, @Param("needUpdate") IsStatus needUpdate);
	
	@Update("update file_module set need_update = #{needUpdate} where module = #{module} and group_id = #{groupId}")
	public void updateStateByModule(@Param("module") String module, @Param("groupId") Integer groupId, @Param("needUpdate") IsStatus needUpdate);
	
	@Update("update file_module set version = #{version}, update_timestamp = #{updateTimestamp} where module = #{module} and group_id = #{groupId}")
	public void updateVersion(@Param("module") String module, @Param("groupId") Integer groupId, @Param("version") String version, @Param("updateTimestamp") Integer updateTimestamp);
	
}
